package cn.lyjuan.pojoutils.factory;

import cn.lyjuan.pojoutils.bean.DBType;
import cn.lyjuan.pojoutils.genclass.IGenClass;
import cn.lyjuan.pojoutils.genclass.ITableInfo;
import cn.lyjuan.pojoutils.genclass.AGenClass;
import cn.lyjuan.pojoutils.genclass.impl.MySQLTableInfoImpl;
import cn.lyjuan.pojoutils.template.IMapperTemplate;
import cn.lyjuan.pojoutils.template.IMapperXMLTemplate;
import cn.lyjuan.pojoutils.template.impl.AMapperXMLTemplate;
import cn.lyjuan.pojoutils.template.impl.AMapperTemplateImpl;

/**
 * Created by ly on 2014/11/20.
 */
public class GenClassFactory
{
    /**
     * 根据数据库类型指定解析表信息的生成工具
     *
     * @param dbType
     * @return
     */
    public static ITableInfo disTableInfo(DBType dbType)
    {
        ITableInfo tableInfo = null;
        switch (dbType)
        {
            case ORACLE:
                throw new RuntimeException("nonsupport Oracle Database");
            case MYSQL:
                tableInfo = new MySQLTableInfoImpl();
                break;
        }

        return tableInfo;
    }

    /**
     * 根据数据库类型指定 Mapper 接口生成工具
     *
     * @param dbType
     * @return
     */
    public static IMapperTemplate disMapperTemplate(DBType dbType)
    {
        return new AMapperTemplateImpl();
    }

    /**
     * 根据数据库类型指定 Mapper XML 文件生成工具
     *
     * @param dbType
     * @return
     */
    public static IMapperXMLTemplate disMapperXMLTemplate(DBType dbType)
    {
        IMapperXMLTemplate temp = null;
        switch (dbType)
        {
            case ORACLE:
                throw new RuntimeException("nonsupport Oracle Database");
            case MYSQL:
                temp = new AMapperXMLTemplate();
                break;
        }

        return temp;
    }

    public static IGenClass disGenClass(DBType dbType)
    {
        return new AGenClass();
    }
}
